function createWebSocket(){
  return new Promise((resolve, reject) => {
    //连接上ws服务器
    const ws=new WebSocket('ws://localhost:8080');
    //监听ws是否连接成功
    ws.onopen=function(){
      resolve(ws);
    };
    //监听ws错误事件
    ws.onerror=function(e){
      reject(e);
    }
  })
};

export default createWebSocket